package user

import (
	"BookStack/pkg/utils"
)

// RegisterRequest 注册请求
type RegisterRequest struct {
	Username string `json:"username" binding:"required,min=3,max=20"`
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required,min=6,max=20"`
	Nickname string `json:"nickname" binding:"max=50"`
}

// RegisterResponse 注册响应
type RegisterResponse struct {
	ID       uint   `json:"id"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Nickname string `json:"nickname"`
}

// LoginRequest 登录请求
type LoginRequest struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

// LoginResponse 登录响应
type LoginResponse struct {
	ID       uint   `json:"id"`
	Username string `json:"username"`
	Nickname string `json:"nickname"`
	Avatar   string `json:"avatar"`
	Role     string `json:"role"`
	Token    string `json:"token,omitempty"`
}

// ProfileResponse 用户信息响应
type ProfileResponse struct {
	ID        uint           `json:"id"`
	Username  string         `json:"username"`
	Email     string         `json:"email"`
	Nickname  string         `json:"nickname"`
	Avatar    string         `json:"avatar"`
	Role      string         `json:"role"`
	Status    int            `json:"status"`
	CreatedAt utils.JSONTime `json:"created_at"`
}

// UpdateProfileRequest 更新用户信息请求
type UpdateProfileRequest struct {
	Nickname string `json:"nickname" binding:"max=50"`
	Avatar   string `json:"avatar" binding:"max=255"`
}

// ChangePasswordRequest 修改密码请求
type ChangePasswordRequest struct {
	OldPassword string `json:"old_password" binding:"required"`
	NewPassword string `json:"new_password" binding:"required,min=6,max=20"`
}

// UserResponse 用户列表项响应
type UserResponse struct {
	ID        uint           `json:"id"`
	Username  string         `json:"username"`
	Email     string         `json:"email"`
	Nickname  string         `json:"nickname"`
	Avatar    string         `json:"avatar"`
	Role      string         `json:"role"`
	Status    int            `json:"status"`
	CreatedAt utils.JSONTime `json:"created_at"`
}

// UserListResponse 用户列表响应
type UserListResponse struct {
	Total int64           `json:"total"`
	Items []*UserResponse `json:"items"`
}
